<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/aui-pull-refresh.css"/>
		<style>
		.aui-list-item {
			line-height: 3.5rem;
		}
		</style>
	</head>
	<body>

		<div style="position: fixed;top: 0;width: 100%;z-index: 100;" id="ast">
			<div class="aui-searchbar" id="search">
				<div class="aui-searchbar-input aui-border-radius" tapmode>
					<i class="aui-iconfont aui-icon-search"></i>
					<form action="javascript:doSearch();">
						<input type="search" placeholder="请输入搜索内容" id="search-input">
					</form>
				</div>
				<div class="aui-searchbar-btn" tapmode>
					取消
				</div>
			</div></div>
			<section class="aui-refresh-content" id="pContainer1">
			<!--<button onclick="show('371327199008111269')">身份测试----</button>-->
			<div class="aui-content">
				<ul class="aui-list aui-list-in" tapmode id="list"></ul>
			</div>
		</section>
	</body>
	<script id="listTemplate" type="text/x-dot-template">
		{{for(var i=0;i<it.list.length;i++){}}
		<li class="aui-list-item aui-list-item-middle" tapmode onclick="show('{{=it.list[i].olderIdCardNumber}}')">
		<div class="aui-list-item-inner aui-list-item-arrow">
		<b>{{=it.list[i].olderName}}</b>
		</li>
		{{}}}
	</script>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/doT.js"></script>
	<script type="text/javascript" src="../../script/util.js"></script>
	<script type="text/javascript" src="../../script/aui-pull-refresh.js"></script>
	<script type="text/javascript">
		var pageNumber = 1;
		var searchText = '';
		apiready = function() {
			api.parseTapmode();
			loadData(pageNumber, searchText);
		};
		var pullRefresh = new auiPullToRefresh({
			container : document.querySelector('.aui-refresh-content'),
			triggerDistance : 100
		}, function(ret) {
			if (ret.status == "success") {
				loadData(++pageNumber, searchText);
			}
		});
		var searchBar = document.querySelector(".aui-searchbar-input");
		if (searchBar) {
			searchBar.onclick = function() {
				document.querySelector(".aui-searchbar-btn").style.marginRight = 0;
			}
		}
		document.querySelector(".aui-searchbar-btn").onclick = function() {
			this.style.marginRight = "-" + this.offsetWidth + "px";
			document.getElementById("search-input").value = '';
			document.getElementById("search-input").blur();
			$api.html($api.byId('list'), '');
			pageNumber = 1;
			loadData(pageNumber, searchText);
		}


		function doSearch() {
			var searchValue = document.getElementById("search-input").value;
			if (searchValue) {
				$api.html($api.byId('list'), '');
				loadData(1, searchValue);
				pageNumber = 0;
			}
		}
		function reashlist() {
				$api.html($api.byId('list'), '');
				loadData(1, '');
		}
		function loadData(pageNumber, searchText) {
		 pContainer1.style.marginTop = $api.byId('ast').clientHeight + 'px';
			api.showProgress({
			});
			api.ajax({
				url : base + '/gero/api/nurseTerminal/idCardInfoCollect/needIdCardInfoCollectOrderPagingQuery',
				method : 'post',
				data : {
					values : {
						pageNo : pageNumber,
						pageSize : '30',
						token : $api.getStorage('userinfo').token,
						olderName : searchText
					}
				}
			}, function(ret, err) {
				console.log(JSON.stringify(ret));
				if (ret && ret.code == "200") {
					var template = $api.byId('listTemplate');
					var list_content = $api.byId('list');
					var pagefn = doT.template(template.text);
					list_content.insertAdjacentHTML('afterbegin', pagefn(ret));
					pullRefresh.cancelLoading();
				} else {
					doLogin();
				}
				api.hideProgress();
			});
		}

		// 查看详情
		function show(cardid) {
//			api.openApp({
//				androidPkg : 'android_serialport_api.sample'
//			}, function(ret, err) {
//				console.log("999999");
//				if (err) {
//					tips('请先下载身份证感应识别APP');
//				}
//			});
			openBrowse(api.wgtRootDir + '/html/card/index.html', '身份识别', false, 'card_show', cardid);
		}
	</script>
</html>
